package ui.activity.order.biz;

import java.util.List;

import Bean.OrderDetailsNewBean;
import base.BaseBiz;
import base.BaseResp;
import coom.BaseSubscribe;
import coom.RetrofitHelp;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import ui.activity.poscontrol.beanmodel.OrderSn;

/**
 * Created by chenjian on 19/2/26.
 * 1
 */

public class OrderDetailsBiz extends BaseBiz {


    /**
     * 获取订单详情
     */
    public void getOrderInfo(String orderId, final Callback<OrderDetailsNewBean> callback) {
        com.add(RetrofitHelp.getSecretApi().getOrderDetails(orderId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe<BaseResp<OrderDetailsNewBean>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((OrderDetailsNewBean) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((OrderDetailsNewBean) obj);
                    }
                })
        );
    }
    /**
     * 查询可回拨终端设备
     */
    public void queryOrderSnList(String orderId,final Callback<List<OrderSn>> callback) {
        String url = RetrofitHelp.BASE_URL + "api/instance/list/" + orderId;
        com.add(RetrofitHelp.getSecretApi().getOrderSn(url)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe<BaseResp<List<OrderSn>>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((List<OrderSn>) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((List<OrderSn>) obj);
                    }
                })
        );
    }

}
